<template>
 <view>
  <view class="" style="text-align: center;">
  	<view style="font-size: 100upx;margin: 20upx 0upx 0upx;">{{levelPrice}}</view>
  </view>
	<view style="display: flex;height: 60upx;line-height: 60upx;margin-left: 200upx;">
		<view style="font-size: 32upx;font-weight: 550;">
			提现金额:
		</view>
		<input style="height: 60upx;line-height: 60upx;" type="number" v-model="price" />
	</view>
	<view style="height: 100upx;width: 200upx;margin-left: 275upx;margin-top: 20upx;">
		<button type="primary" @click="withdraw">提现</button>
	</view>
	<view style="background-color: #fff;width: 90%;margin:0upx 5%;border-radius: 10upx;">
		<view style="width: 100;position: relative;" v-for="(item,index) in bankcard_list" :key="index">
			<image style="height: 300upx;width: 675upx" src="../../../../static/jianhang.png" mode="" @click="jumpToEdit(item.id)" ></image>
			<view style="position: absolute;bottom: 50upx;left: 100upx;z-index: 10;color: #fff;">
				<view style="font-size: 38upx;">
					{{item.name}}
				</view>
				<view style="font-size: 38upx;">
					{{item.bankNo}}
				</view>
			</view>
		</view>
		
	</view>
	<view class="" style="text-align: center;color: #868686;">
		<text @click="jump" data-src="./record" >提现记录</text>
		<text style="margin: 0upx 20upx;">|</text>
		<text> 提现说明</text>
		<text style="margin: 0upx 20upx;">|</text>
		<text  @click="tobankcard"> 添加银行卡</text>
	</view>
 </view>
</template>

<script>
 export default {
  data() {
   return {
    res:[],
    user_id:'',
    bankcard_list:'',
		price:'',
		levelPrice:'',
   };
  },
  onLoad:function(){
   uni.showLoading()
   uni.getStorage({
    key: 'user_id',
    success: (res) => {
     this.user_id = res.data
     this.setAjax()
		 this.levelPrice1()
    },
    fail: () => {
     uni.navigateTo({
      url: '../../index/index'
     });
    }
   });
  },
  methods:{
   setAjax(){
		 // 银行卡列表
    uni.request({
     url: 'https://cx.mingmeijt.com/Api/UserBank/index',
     method: 'POST',
     header:{'Content-Type':'application/x-www-form-urlencoded'},
     data:{
      user_id: this.user_id,
     },
     success: res => {
			 this.bankcard_list = res.data.data
			 console.log(this.bankcard_list)
     },
     fail: () => {},
     complete: () => {}
    });
    uni.hideLoading()
   },
	 levelPrice1() {
	 		 uni.request({
	 		  url: 'https://cx.mingmeijt.com/Api/User/myPurse',
	 		  method: 'POST',
	 		  header:{'Content-Type':'application/x-www-form-urlencoded'},
	 		  data:{
	 		   user_id: this.user_id,
	 		  },
	 		  success: res => {
	 		 	 console.log(res)
	 			 	this.levelPrice = res.data.data.levelPrice
	 		  },
	 		  fail: () => {},
	 		  complete: () => {}
	 		 });
	 },
	 // 申请提现
	 withdraw() {
		 uni.request({
		  url: 'https://cx.mingmeijt.com/Api/WithdrawOrder/createWithdrawOrder',
		  method: 'POST',
		  header:{'Content-Type':'application/x-www-form-urlencoded'},
		  data:{
		   user_id: this.user_id,
		   user_bank_id: this.bankcard_list[0].id,
		   price: this.price,
			 
		  },
		  success: res => {
		 	 console.log(res)
			 uni.showToast({
			 	title: res.data.msg
			 })
			 // if(res.data.code == 200) {
			 // 	setTimeout(function() {
			 // 		uni.reLaunch({
			 // 			url: './qianbao'
			 // 		})
			 // 	}, 1500);
			 // }
		  },
		  fail: () => {},
		  complete: () => {}
		 });
	 },
   jump(e){
    uni.navigateTo({
     url: e.currentTarget.dataset.src
    });
   },
	 jumpToEdit(id){
	  uni.navigateTo({
	   url: '../bankcard?bankid=' + id
	  });
	 },
	 tobankcard: function(){
		 uni.navigateTo({
		 	url:'../bankcard'
		 })
	 },
  }
 }
</script>

<style>
	page{background-color: #fff;}
</style>